/**
 * @file
 * @author  michal.nezerka@gmail.com
 * @brief   Application Class Declaration
 */

#ifndef WWAPP_H
#define WWAPP_H

#include <vector>
#include <list>

#include <wx/app.h>
#include <wx/fileconf.h>
#include <wx/config.h>

#include "mainwnd.h"
#include "gpxdb.h"
#include "geoutils.h"

namespace wildwood
{

/** \brief Structure which encapsulates all application configuration parameters */
struct AppSettings
{
    /// Path to db file
    wxString mDbPath;

    GeoPos mDefaultPos;
    GeoPos mLastPos;
    int mDefaultZoom;

    /// Ctor
    AppSettings();

    /// Load configuration data from Config class
    void LoadFromConfig(wxConfig *config);

    /// Save configuration data to Config class
    void SaveToConfig(wxConfig *config);
};

/** \brief Application class singleton */
class App : public wxApp
{
public:
    App() : wxApp(), mFrame(NULL) { }

    /// Current application configuration
    wxConfig *config;

    /// Application settings
    AppSettings *mSettings;

    /// Gpx database
    GpxDb mGpxDb;

     /// Called by wx framework on initialization of application
    virtual bool OnInit();

    /// Called by wx framework when application is closed
    virtual int OnExit();

    /// Called by wx framework when log target is created
    virtual wxLog* CreateLogTarget();

    /// Writes message to the info channel (log window)
    virtual void info(wxString fmt, ...);

private:
    class MainWnd *mFrame;
};

} // namespace

DECLARE_APP(wildwood::App);

#endif // WWAPP_H
